package program.Junction;

import Exceptions.IllegalCoordinateException;
import Exceptions.ShootException;
import program.Atom;
import program.SExprList;
import program.SExpression;
import program.Condition.Condition;
import roborally.Robot;

/**
 * A class representing the NOT junction.
 * 
 * @author Jef Keijers/Bachelor of Science: Informatics
 * @version 1.0
 */
public class NotCase extends Condition {
	/**
	 * This constructor instantiate a new NotCase instance and sets the condition to the given condition.
	 * @param condition1
	 */
	public NotCase(Condition condition1) {
		this.condition1=condition1;
	}
	
	/**
	 * Returns true if the method called returns false.
	 */
	@Override
	public boolean execute(Robot robot) throws ShootException, IllegalCoordinateException {
		return !(condition1.execute(robot));
	}
	
	/**
	 * Returns the SExpression representation of the NOT CASE junction.
	 */
	@Override
	public SExpression toSExpression() {
		SExprList sexpr = new SExprList();
		sexpr.add(new Atom("not"));
		sexpr.add(condition1.toSExpression());
		return sexpr;
	}
	
	/**
	 * Instance variable representing condition 1 of the NOT junction.
	 */
	private Condition condition1;
}


